<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/template-web.js"></script>
</head>
<div id="box"></div>

<body>
    <script type="text/html" id="tpl-user">
        {{each array}}
        {{if $index % 2 ===0}}
        <div class="even">{{$value}}</div>
        {{else if $index % 2 !==0}}
        <div class="odd">{{$value}}</div>
        {{/if}}
        {{/each}}
    </script>

    <script>
        let data = {
            array: [
                '知人者智，自知者明。胜人者有力，自胜者强',
                '一个人即使已登上顶峰，也仍要自强不息',
                '要掌握书，莫被书掌握；要为生而读，莫为读而生',
                '业精于勤，荒于嬉；行成于思，毁于随',
                '只要持续地努力，不懈地奋斗，就没有征服不了的东西',
                '既然我已经踏上这条道路，那么，任何东西都不应妨碍我沿着这条路走下去',
                '滴 滴滴~',
            ],
        };
        var htmlStr = template('tpl-user', data)
        console.log(htmlStr);
        document.getElementById('box').innerHTML = htmlStr
    </script>
</body>

</html>